package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.controlle.MenuLevelTreeBuilder;
import com.ruoyi.system.domain.FileData;
import com.ruoyi.system.domain.FileDataLog;
import com.ruoyi.system.domain.MenuLevel;
import com.ruoyi.system.mapper.FileDataLogMapper;
import com.ruoyi.system.mapper.FileDataMapper;
import com.ruoyi.system.mapper.MenuLevelMapper;
import com.ruoyi.system.service.MenuLevelService;
import com.ruoyi.system.service.fileDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 用户 业务层处理
 * 
 * @author ruoyi
 */
@Service
public class MenuLevelServiceImpl implements MenuLevelService
{
    private static final Logger log = LoggerFactory.getLogger(MenuLevelServiceImpl.class);

    @Autowired
    private MenuLevelMapper menuLevelMapper;


    @Override
    public List<MenuLevel> selectFileDataList(MenuLevel menuLevel) {
        List<MenuLevel> dataList = menuLevelMapper.selectFileDataList(menuLevel);
        // 创建构建器并构建树
        MenuLevelTreeBuilder builder = new MenuLevelTreeBuilder();
        List<MenuLevel> categoryTree = builder.buildTree(dataList);

        // 打印树形结构
    /*    for (MenuLevel root : categoryTree) {
            builder.printTree(root, 0);
        }*/
        return  categoryTree;
    }

    @Override
    public int insertMenuLevel(MenuLevel menulevel) {
        return menuLevelMapper.insertMenuLevel(menulevel);
    }

    @Override
    public int update(MenuLevel menuLevelList) {

       /* for (int i = 0; i < menuLevelList.size(); i++) {
            menuLevelMapper.updateLeve(menuLevelList.get(i));

        }*/
        menuLevelMapper.updateLeve(menuLevelList);

        return  0;
    }


}
